sequenceDiagram
        actor UserA
        participant PeerConnectionA
        participant PeerA
        participant Server
        participant Coturn
        participant PeerB
        participant PeerConnectionB
        actor UserB
        # 登录
        Note over UserA,UserB: === 登录阶段 ===
        UserA->>PeerA: login
        PeerA->>Server: loginReq
        Server-->>PeerA: loginRes
        UserB->>PeerB: login
        PeerB->>Server: loginReq
        Server-->>PeerB: loginRes
        # 呼叫
        Note over UserA,UserB: === 呼叫阶段 ===
        UserA->>PeerA: make call
        PeerA->>Server: callMakeReq
        Server->>PeerB: callMakeNotify
        UserB->>PeerB: accept call
        PeerB-->>Server: callMakeAck
        Server-->>PeerA: callMakeRes
        # 连接建立
        PeerA->>UserA: connecting
        PeerB->>UserB: connecting
        PeerA-->>PeerConnectionA: create
        PeerA->>PeerConnectionA: addTransceiver(inactive)
        PeerA->>PeerConnectionA: createOffer
        PeerConnectionA-->>Coturn: getCandidates
        PeerConnectionA-->>PeerA: onCreateOfferSuccess(sdp)
        PeerA->>PeerConnectionA: setLocalDescription
        PeerA->>Server: negotiateReq(sdp)
        Server->>PeerB: negotiateReq(sdp)
        PeerB-->>PeerConnectionB: create
        PeerB->>PeerConnectionB: setRemoteDescription
        PeerB->>PeerConnectionB: createAnswer
        PeerConnectionB-->>Coturn: getCandidates
        PeerConnectionB-->>PeerB: onCreateAnswerSuccess(sdp)
        PeerB->>PeerConnectionB: setLocalDescription
        PeerB->>UserB: connected
        PeerB->>Server: negotiateRes(sdp)
        Server-->>PeerA: negotiateRes(sdp)
        PeerA->>PeerConnectionA: setRemoteDescription
        PeerA->>UserA: connected
        # 发布
        Note over UserA,UserB: === 发布阶段 ===
        UserA->>PeerA: publish(media)
        PeerA->>Server: publishReq
        Server-->>PeerA: publishRes
        Server->>PeerB: publishNotify
        PeerB-->>Server: publishAck
        # 订阅
        Note over UserA,UserB: === 订阅阶段 ===
        UserB->>PeerB: subscribe
        PeerB->>Server: subscribeReq
		Server->>PeerB: subscribeRes
        Server-->>PeerA: startProduceNotify
        PeerA->>Server: startProduceAck
        # 协商
        PeerA->>PeerConnectionA: addTrack
        PeerA->>PeerConnectionA: createOffer
        PeerConnectionA-->>PeerA: onCreateOfferSuccess(offer)
        PeerA->>PeerConnectionA: setLocalDescription
        PeerA->>Server: negotiateReq(offer)
        Server->>PeerB: negotiateNotify(offer)
        PeerB->>PeerConnectionB: setRemoteDescription
        PeerB->>PeerConnectionB: createAnswer
        PeerConnectionB-->>PeerB: onCreateAnswerSuccess(answer)
        PeerB->>PeerConnectionB: setLocalDescription
        PeerB-->>Server: renegotiateAck(answer)
        Server-->>PeerA: renegotiateRes(answer)
        PeerA->>PeerConnectionA: setRemoteDescription
        
		Note over UserA,UserB: === 取消订阅 ===
		UserB->>PeerB: unsubscribe
		PeerB->>Server: unsubscribeReq
		Server-->>PeerB: unsubscribeRes
		Server->>PeerA: stopProduceNotify
		PeerA-->>Server: stopProduceAck
		PeerA->>PeerConnectionA: removeTrack

		Note over UserA,UserB: === 取消发布 ===
		UserA->>PeerA: stopPublish(media)
		PeerA->>Server: stopPublishReq(media)
		Server-->>PeerA: stopPublishRes
		PeerA->>PeerConnectionA: removeTrack(media)
		Server->>PeerB: stopPublishNotify(media)
		PeerB-->>Server: stopPublishAck